package com.amiu.shiro.db.user_role;

import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


public interface UserRoleDao {
	@Insert("INSERT INTO user_roles (user_id,role_id,description) VALUES(#{user_id},#{role_id},#{description})")
	public void createUserRole(UserRole userRole);
	
	public void deleteUserRole(Long id);
	
	public void updateUserRole(Long id);
	
	@Select("SELECT id,user_id,role_id,description FROM user_roles WHERE id = #{id}")
	public UserRole findById(Long id);
	
	@MapKey("id")
	@Select("SELECT id,user_id,role_id,description FROM user_roles WHERE user_id = #{user_id}")
	public Map<Long,UserRole> findByUserId(Long user_id);
	
	//@MapKey("id")
	@Select("SELECT id,user_id,role_id,description FROM user_roles WHERE user_id = #{user_id} AND role_id=#{role_id}")
	public UserRole findByUserIdAndRoleId(@Param("user_id")Long user_id,@Param("role_id")Long role_id);
}
